Ext.regModel('Board', {
	fields : [ {
		name : 'serial',
		type : 'int'
	}, {
		name : 'subject',
		type : 'string'
	}, {
		name : 'content',
		type : 'string'
	}, {
		name : 'writer',
		type : 'string'
	}, {
		name : 'writtenDate',
		type : 'string'
	} ]
});

// 4. 데이터 접근.
function boardData() {
	// 데이터 읽기.
	var record = boardStore.getAt(0);
	console.log(record);
	console.log(record.data.id);
	console.log(record.data.firstName);
	console.log(record.data["lastName"]);
}

var boardStoreListener = {
	add : function() {
		console.log("add");
	},
	beforeload : function() {
		console.log("beforeload");
	},
	datachanged : function() {
		console.log("datachanged");
	},
	exception : function() {
		console.log("exception");
	},
	load : function() {
		console.log("load");
	},
	remove : function() {
		console.log("remove___");
	},
	update : function() {
		console.log("loadexception");
	}
}

var boardProxy = new Ext.data.AjaxProxy({
	// url: 'http://192.168.0.74:8080/simple-webapp/json', 안된다.... 이유는 모르겠다
	url : '/simple-webapp/searchJsonBoard.do',
	type : 'ajax',
	model : 'Board',
	reader : {
		type : 'json',
		root : 'result'
	}
});
// 3. Store생성.
var boardStore = new Ext.data.JsonStore({
	model : 'Board',
	encode : 'true',
	proxy : boardProxy
});
boardStore.sort('serial', 'DESC');
boardStore.load();

var boardList = new Ext.List({
	fullscreen : true,
	store : boardStore,
	listeners : {
		itemtap : function(dv, ix, item, e) {
			alert(this.store.getAt(ix).data.serial);
		}
	},
	itemTpl : '<div class="board_service">{serial}  {subject} {writer}  {writtenDate}<br/>{content}</div>'
});

/*
var boardColumn = new Ext.grid.ColumnModel([ {
	header : '번호',
	sortable : true,
	dataIndex : 'serial',
	width : 80
}, {
	header : '제목',
	sortable : true,
	dataIndex : 'serial',
	width : 200
}, {
	header : '내용',
	sortable : false,
	dataIndex : 'content',
	width : 100
}, {
	header : '작성자',
	sortable : true,
	dataIndex : 'writer',
	width : 100
}, {
	header : '작성일',
	sortable : true,
	dataIndex : 'writtenDate',
	width : 100
} ]);

// 4. 그리드 패널 만들기
var boardList = new Ext.grid.GridPanel({
	renderTo : Ext.getBody(),
	id : 'my-grid',
	title : '게시판',
	height : 300,
	width : 500,
	cm : boardColumn,
	store : boardStore
});
*/